<?php
/**
 * Created by PhpStorm.
 * User: kaycn
 * Date: 18-9-20
 * Time: 上午8:33
 */
namespace Jpay;

class Data{

    public static $data;

    public $json;

    public function __construct($data)
    {
        self::$data = $data;

        $this->deeldata();
    }
    public function deeldata(){

        self::$data = preg_replace('/\\\n/',"",self::$data);


        if(preg_match('/\[/',self::$data)){

            self::$data = json_decode(self::$data,true);

            self::$data[0] = "20018-1111";

            $this->json = json_encode(self::$data);


//
//            self::$data = preg_replace('/\[/',"",self::$data);
//
//            self::$data = preg_replace('/\]/',"",self::$data);

            // preg_match_all("/\{[^{]+\}/i",self::$data,self::$data);

            //  self::$data = self::$data[0];

            //规范json构造

//            foreach (self::$data[0] as $key => $val){
//
//                $this->json = $this->json.$key.":".json_encode($val);
//
//            }
//            $this->json = '{'.$this->json.'}';

        }
        else{

            $this->json = self::$data;

            echo 2;

            self::$data = json_decode(self::$data,true);

        }




    }
}